define(['jquery', 'echarts'], function ($, Echarts) {
    function flow() {
        var EchartsModel;
        EchartsModel = Echarts;
        $.ajax({
            url: "/manager.php/flow/chartDayFlow",
            type: "POST",
            dataType: 'json',
            data: {starttime: null, endtime: null},
            async: true,
            success: function (res) {
                if (res.code == 1) {
                    let data = res.data;
                    console.log(data)
                    dataArr = data['data'];//数据
                    daysArr = data['days'];//时间
                    typeArr = data['type'];//类别
                    var EchartsModel;
                    EchartsModel = Echarts;
                    var myChart = EchartsModel.init(document.getElementById('day-flowmain'));
                    option = {
                        title: {
                            // text: '今日流量统计',
                            subtext:'今日流量统计',
                            // x:'center',
                            // y:'top',
                            // textAlign:'center'
                        },
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                label: {
                                    backgroundColor: '#6a7985'
                                }
                            }
                        },
                        legend: {
                            data: typeArr
                        },
                        toolbox: {
                            feature: {
                                saveAsImage: {
                                    show: false
                                }
                            }
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: 'category',
                                boundaryGap: false,
                                data: daysArr,
                                axisLine: {
                                    show: true, //是否显示轴线
                                    lineStyle: {
                                        color: '#009688', //刻度线的颜色
                                        width: 2,
                                    }
                                }
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value',
                                axisLine: {
                                    show: true, //是否显示轴线
                                    lineStyle: {
                                        color: '#009688', //刻度线的颜色
                                        width: 2,
                                    },
                                    emphasis: {
                                        // 选中的时候的效果
                                        lineStyle: {
                                            width: 3,
                                        }
                                    }
                                },

                            }
                        ],
                        series: [
                            {
                                name: '电脑',
                                type: 'line',
                                stack: 'Total',
                                areaStyle: {},
                                emphasis: {
                                    focus: 'series'
                                },
                                data: dataArr['computer']
                            },
                            {
                                name: '手机',
                                type: 'line',
                                stack: 'Total',
                                areaStyle: {},
                                emphasis: {
                                    focus: 'series'
                                },
                                data: dataArr['phone']
                            },
                        ],

                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                }
            }
        })
    }

    flow();

})
